package com.adjy.pathbuilders.scenario.internal;

import com.adjy.pathbuilders.world.LevelCategory;

/**
 * ScenarioDescription holds the information to create a Scenario
 */
public class ScenarioDescription {

	private static final String LINE_DELIMITER = ":";

	private LevelCategory category;
	private String scenarioId;
	private String path;

	/**
	 * Constructor for ScenarioDescription
	 * 
	 * @param category
	 *            Category
	 * @param id
	 *            Scenario ID
	 * @param path
	 *            Path to load the Scenario
	 */
	private ScenarioDescription(LevelCategory category, String id, String path) {
		this.category = category;
		this.scenarioId = id;
		this.path = path;
	}

	/**
	 * Gets the Category for this Scenario
	 * 
	 * @return LevelCategory
	 */
	public LevelCategory getCategory() {
		return category;
	}

	/**
	 * Gets the ID for this Scenario
	 * 
	 * @return String - Scenario ID
	 */
	public String getScenarioID() {
		return scenarioId;
	}

	/**
	 * Gets the Path to load the Scenario
	 * 
	 * @return String - Path to the Scenario
	 */
	public String getScenarioPath() {
		return path;
	}

	/**
	 * Loads the given String to create a ScenarioDescription
	 * 
	 * @param line
	 *            Line to create a ScenarioDescription
	 * @return created ScenarioDescription
	 */
	public static ScenarioDescription load(String line) {

		try {
			String[] properties = line.split(LINE_DELIMITER);
			LevelCategory category = LevelCategory
					.getCategoryFor(properties[1]);

			return new ScenarioDescription(category, properties[0],
					properties[2]);

		} catch (Exception e) {
			return null;
		}

	}

}
